﻿using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using Microsoft.VisualStudio.Tools.Applications.Runtime;


using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using WordDoc = Microsoft.Office.Interop.Word.Document;


namespace WordTemplate2
{
    public partial class ThisDocument
    {
        public static WordDoc doc = null;
        public static bool skip_check_flag = true;
        public static string current_header = "QRJ ××××－××××\r";

        Office.CommandBar commandToolbar_QRJ_Main = null;
        Office.CommandBar commandToolbar_QRJ_Chapter = null;
        Office.CommandBar commandToolbar_QRJ_Appendix = null;

        Office.CommandBarPopup subbutton_lv1;
        Office.CommandBarPopup subbutton_lv2;

        Office.CommandBarButton button_0_1_0;
        Office.CommandBarButton button_0_1_1;
        Office.CommandBarButton button_0_1_2;
        Office.CommandBarButton button_0_1_3;
        Office.CommandBarButton button_0_1_4;
        Office.CommandBarButton button_0_1_5;
        Office.CommandBarButton button_0_1_6;
        Office.CommandBarButton button_0_1_7;
        Office.CommandBarButton button_0_1_8;
        Office.CommandBarButton button_0_1_9;
        Office.CommandBarButton button_0_1_10;
        Office.CommandBarButton button_0_1_11;
        Office.CommandBarButton button_0_1_12;

        Office.CommandBarButton button_0_2_0;
        Office.CommandBarButton button_0_2_1;
        Office.CommandBarButton button_0_2_2;
        Office.CommandBarButton button_0_2_3;
        Office.CommandBarButton button_0_2_4;
        Office.CommandBarButton button_0_2_5;
        Office.CommandBarButton button_0_2_6;
        Office.CommandBarButton button_0_2_7;
        Office.CommandBarButton button_0_2_8;

        Office.CommandBarButton button_0_3_0;
        Office.CommandBarButton button_0_3_1;
        Office.CommandBarButton button_0_3_2;
        Office.CommandBarButton button_0_3_3;
        Office.CommandBarButton button_0_3_4;
        Office.CommandBarButton button_0_3_5;

        Office.CommandBarButton button_0_4_0;

        Office.CommandBarButton button_0_5_0;

        Office.CommandBarButton button_0_6_0;
        Office.CommandBarButton button_0_6_1;
        Office.CommandBarButton button_0_6_2;
        Office.CommandBarButton button_0_6_3;

        Office.CommandBarButton button_0_7_0;

        Office.CommandBarButton button_1_1_0;
        Office.CommandBarButton button_1_2_0;
        Office.CommandBarButton button_1_3_0;
        Office.CommandBarButton button_1_4_0;
        Office.CommandBarButton button_1_5_0;
        Office.CommandBarButton button_1_6_0;
        Office.CommandBarButton button_1_7_0;
        Office.CommandBarButton button_1_8_0;
        Office.CommandBarButton button_1_9_0;
        Office.CommandBarButton button_1_10_0;
        Office.CommandBarButton button_1_11_0;
        Office.CommandBarButton button_1_12_0;
        Office.CommandBarButton button_1_13_0;

        Office.CommandBarButton button_1_14_0;
        Office.CommandBarButton button_1_14_1;
        Office.CommandBarButton button_1_14_2;
        Office.CommandBarButton button_1_14_3;

        Office.CommandBarButton button_1_15_0;
        Office.CommandBarButton button_1_16_0;
        Office.CommandBarButton button_1_17_0;
        Office.CommandBarButton button_1_18_0;

        Office.CommandBarButton button_2_1_0;
        Office.CommandBarButton button_2_2_0;
        Office.CommandBarButton button_2_3_0;
        Office.CommandBarButton button_2_4_0;
        Office.CommandBarButton button_2_5_0;
        Office.CommandBarButton button_2_6_0;
        Office.CommandBarButton button_2_7_0;
        Office.CommandBarButton button_2_8_0;
        Office.CommandBarButton button_2_9_0;
        Office.CommandBarButton button_2_10_0;





        private void ThisDocument_Startup(object sender, System.EventArgs e)
        {
            CreateCommandBar(this.Application);
            System.Collections.IEnumerator dou = Globals.ThisDocument.Application.Documents.GetEnumerator();
            while (dou.MoveNext())
            {
                Word.Document d = (Word.Document)dou.Current;
                index_filename = d.FullName;
            }
            Globals.ThisDocument.Application.ActiveDocument.ActiveWindow.View.ShowAll = true;
        }

        private void ThisDocument_Shutdown(object sender, System.EventArgs e)
        {
            DestoryCommandBar(this.Application);
        }

        private void ThisDocument_BeforeSave(object sender, Microsoft.Office.Tools.Word.SaveEventArgs e)
        {
            System.Windows.Forms.SaveFileDialog dialog = new System.Windows.Forms.SaveFileDialog();
            dialog.RestoreDirectory = true;
            dialog.FileName = "中国航天科技集团公司第八研究院标准";
            dialog.Filter = "Word文档(*.doc)|*.doc";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                //获得文件路径   
                string localFilePath = dialog.FileName.ToString().Replace("\\", "/");

                Globals.ThisDocument.SaveTempFile(localFilePath);

                if (ServerDocument.IsCustomized(localFilePath))
                {
                    ServerDocument.RemoveCustomization(localFilePath);
                }

            }
            e.Cancel = true;
        }

       


        public void DestoryCommandBar(Word.Application application)
        {
            if (commandToolbar_QRJ_Main != null)
            {
                commandToolbar_QRJ_Main.Visible = false;
                commandToolbar_QRJ_Main.Delete();
            }

            if (commandToolbar_QRJ_Chapter != null)
            {
                commandToolbar_QRJ_Chapter.Visible = false;
                commandToolbar_QRJ_Chapter.Delete();
            }

            if (commandToolbar_QRJ_Appendix != null)
            {
                commandToolbar_QRJ_Appendix.Visible = false;
                commandToolbar_QRJ_Appendix.Delete();
            }
        }

       

        public void CreateCommandBar(Word.Application application)
        {

            #region FirstLine
            {
                commandToolbar_QRJ_Main = Globals.ThisDocument.GetCommandBar(application, "QRJ_Main");
                if (commandToolbar_QRJ_Main != null)
                {
                    commandToolbar_QRJ_Main.Visible = false;
                    commandToolbar_QRJ_Main.Delete();
                }




                {
                    commandToolbar_QRJ_Main = application.CommandBars.Add("QRJ_Main", Office.MsoBarPosition.msoBarTop, missing, true);

                    commandToolbar_QRJ_Main.Visible = true;



                    subbutton_lv1 = (Office.CommandBarPopup)commandToolbar_QRJ_Main.Controls.Add(
                         Office.MsoControlType.msoControlPopup,
                           missing, missing, 1, true);

                    subbutton_lv1.Caption = "文件种类选择";


                    {
                        subbutton_lv2 = (Office.CommandBarPopup)subbutton_lv1.Controls.Add(
                               Office.MsoControlType.msoControlPopup,
                               missing, missing, 1, true);

                        subbutton_lv2.Caption = "新建文件";

                        {
                            button_0_1_0 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_0.FaceId = 43;
                            button_0_1_0.Caption = "标准草案";
                            button_0_1_0.Visible = true;

                            button_0_1_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_0_Click);

                            button_0_1_1 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_1.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_1.FaceId = 43;
                            button_0_1_1.Caption = "相关性查询报告";
                            button_0_1_1.Visible = false;

                            button_0_1_1.Enabled = false;

                            button_0_1_2 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_2.FaceId = 43;
                            button_0_1_2.Caption = "论证报告";
                            button_0_1_2.Visible = true;

                            button_0_1_2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_2_Click);

                            button_0_1_3 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_3.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_3.FaceId = 43;
                            button_0_1_3.Caption = "项目任务书";
                            button_0_1_3.Visible = false;

                            button_0_1_3.Enabled = false;

                            button_0_1_4 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_4.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_4.FaceId = 43;
                            button_0_1_4.Caption = "编制说明";
                            button_0_1_4.Visible = true;

                            button_0_1_4.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_4_Click);

                            button_0_1_5 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_5.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_5.FaceId = 43;
                            button_0_1_5.Caption = "标准报批书";
                            button_0_1_5.Visible = true;

                            button_0_1_5.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_5_Click);

                            button_0_1_6 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_6.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_6.FaceId = 43;
                            button_0_1_6.Caption = "报批文件清单";
                            button_0_1_6.Visible = false;

                            button_0_1_6.Enabled = false;

                            button_0_1_7 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_7.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_7.FaceId = 43;
                            button_0_1_7.Caption = "标准修改单";
                            button_0_1_7.Visible = false;

                            button_0_1_7.Enabled = false;

                            button_0_1_8 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_8.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_8.FaceId = 43;
                            button_0_1_8.Caption = "标准意见汇总处理表";
                            button_0_1_8.Visible = true;

                            button_0_1_8.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_8_Click);

                            button_0_1_9 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_0_1_9.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_0_1_9.FaceId = 43;
                            button_0_1_9.Caption = "复审结论意见表";
                            button_0_1_9.Visible = false;

                            button_0_1_9.Enabled = false;
                        }
                    }

                    {
                        button_0_1_10 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_1_10.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_1_10.FaceId = 43;
                        button_0_1_10.Caption = "打开文件";
                        button_0_1_10.Visible = true;

                        button_0_1_10.Click += new Office._CommandBarButtonEvents_ClickEventHandler(OpenFileBtn_Click);

                        //button_0_1_11 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        //button_0_1_11.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        //button_0_1_11.FaceId = 43;
                        //button_0_1_11.Caption = "去除关联保存文件";
                        //button_0_1_11.Visible = true;

                        //button_0_1_11.Click += new Office._CommandBarButtonEvents_ClickEventHandler(FileSave_Click);

                        button_0_1_12 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_1_12.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_1_12.FaceId = 43;
                        button_0_1_12.Caption = "重新生成页眉页脚";
                        button_0_1_12.Visible = false;

                        button_0_1_12.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_1_12_Click);


                    }



                    subbutton_lv1 = (Office.CommandBarPopup)commandToolbar_QRJ_Main.Controls.Add(
                         Office.MsoControlType.msoControlPopup,
                           missing, missing, 2, true);

                    subbutton_lv1.Caption = "添加,更新标准要素";


                    {
                        button_0_2_0 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_0.FaceId = 43;
                        button_0_2_0.Caption = "修改封面";
                        button_0_2_0.Visible = true;

                        button_0_2_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_0_Click);

                        button_0_2_1 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_1.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_1.FaceId = 43;
                        button_0_2_1.Caption = "添加，更新目次";
                        button_0_2_1.Visible = true;

                        button_0_2_1.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_1_Click);

                        button_0_2_2 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_2.FaceId = 43;
                        button_0_2_2.Caption = "修改前言";
                        button_0_2_2.Visible = true;

                        button_0_2_2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_2_Click);

                        button_0_2_3 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_3.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_3.FaceId = 43;
                        button_0_2_3.Caption = "添加引言";
                        button_0_2_3.Visible = true;

                        button_0_2_3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_3_Click);


                        button_0_2_4 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_4.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_4.FaceId = 43;
                        button_0_2_4.Caption = "添加附录";
                        button_0_2_4.Visible = true;

                        button_0_2_4.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_4_Click);

                        button_0_2_5 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_5.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_5.FaceId = 43;
                        button_0_2_5.Caption = "添加参考文献";
                        button_0_2_5.Visible = true;

                        button_0_2_5.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_5_Click);

                        button_0_2_6 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_6.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_6.FaceId = 43;
                        button_0_2_6.Caption = "添加,更新索引";
                        button_0_2_6.Visible = true;

                        button_0_2_6.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_6_Click);


                        button_0_2_7 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_7.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_7.FaceId = 43;
                        button_0_2_7.Caption = "在当前位置插入横页";
                        button_0_2_7.Visible = true;

                        button_0_2_7.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_7_Click);


                        button_0_2_8 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_2_8.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_2_8.FaceId = 43;
                        button_0_2_8.Caption = "添加终结线";
                        button_0_2_8.Visible = true;

                        button_0_2_8.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_2_8_Click);

                    }

                    subbutton_lv1 = (Office.CommandBarPopup)commandToolbar_QRJ_Main.Controls.Add(
                        Office.MsoControlType.msoControlPopup,
                          missing, missing, 3, true);

                    subbutton_lv1.Caption = "删除标准要素";

                    {
                        button_0_3_0 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_0.FaceId = 43;
                        button_0_3_0.Caption = "删除目次";
                        button_0_3_0.Visible = true;

                        button_0_3_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_0_Click);

                        button_0_3_1 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_1.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_1.FaceId = 43;
                        button_0_3_1.Caption = "删除引言";
                        button_0_3_1.Visible = true;

                        button_0_3_1.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_1_Click);

                        button_0_3_2 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_2.FaceId = 43;
                        button_0_3_2.Caption = "删除附录";
                        button_0_3_2.Visible = true;

                        button_0_3_2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_2_Click);

                        button_0_3_3 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_3.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_3.FaceId = 43;
                        button_0_3_3.Caption = "删除参考文献";
                        button_0_3_3.Visible = true;

                        button_0_3_3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_3_Click);

                        button_0_3_4 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_4.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_4.FaceId = 43;
                        button_0_3_4.Caption = "删除索引";
                        button_0_3_4.Visible = true;

                        button_0_3_4.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_4_Click);

                        button_0_3_5 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_3_5.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_3_5.FaceId = 43;
                        button_0_3_5.Caption = "删除当前横页";
                        button_0_3_5.Visible = true;

                        button_0_3_5.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_3_5_Click);
                    }

                    {
                        button_0_4_0 = (Office.CommandBarButton)commandToolbar_QRJ_Main.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_4_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_4_0.FaceId = 43;
                        button_0_4_0.Caption = "检查附录";
                        button_0_4_0.Visible = true;

                        button_0_4_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_4_0_Click);
                    }

                    {
                        button_0_5_0 = (Office.CommandBarButton)commandToolbar_QRJ_Main.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_5_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_5_0.FaceId = 43;
                        button_0_5_0.Caption = "检查引用文件";
                        button_0_5_0.Visible = true;

                        button_0_5_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_5_0_Click);

                    }

                    {
                        button_0_7_0 = (Office.CommandBarButton)commandToolbar_QRJ_Main.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_7_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_7_0.FaceId = 43;
                        button_0_7_0.Caption = "添加引用文件";
                        button_0_7_0.Visible = true;

                        button_0_7_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_0_7_0_Click);
                    }

                    subbutton_lv1 = (Office.CommandBarPopup)commandToolbar_QRJ_Main.Controls.Add(
                       Office.MsoControlType.msoControlPopup,
                         missing, missing, 7, true);

                    subbutton_lv1.Caption = "帮助";

                    {
                        button_0_6_0 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_6_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_6_0.FaceId = 43;
                        button_0_6_0.Caption = "用户使用指南";
                        button_0_6_0.Visible = false;

                        button_0_6_0.Enabled = false;

                        button_0_6_1 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_6_1.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_6_1.FaceId = 43;
                        button_0_6_1.Caption = "标准编写示例";
                        button_0_6_1.Visible = false;

                        button_0_6_1.Enabled = false;

                        button_0_6_2 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_6_2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_6_2.FaceId = 43;
                        button_0_6_2.Caption = "规范编写示例";
                        button_0_6_2.Visible = false;

                        button_0_6_2.Enabled = false;

                        button_0_6_3 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_0_6_3.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_0_6_3.FaceId = 43;
                        button_0_6_3.Caption = "关于标准编辑器";
                        button_0_6_3.Visible = true;

                        button_0_6_3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(OpenVersionWindow);

                    }
                }
            }
            #endregion

            #region SecondLine
            {
                commandToolbar_QRJ_Chapter = Globals.ThisDocument.GetCommandBar(application, "QRJ_Chapter");
                if (commandToolbar_QRJ_Chapter != null)
                {
                    commandToolbar_QRJ_Chapter.Visible = false;
                    commandToolbar_QRJ_Chapter.Delete();
                }




                {
                    commandToolbar_QRJ_Chapter = application.CommandBars.Add("QRJ_Chapter", Office.MsoBarPosition.msoBarTop, missing, true);

                    commandToolbar_QRJ_Chapter.Visible = true;

                    button_1_1_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_1_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_1_0.FaceId = 43;
                    button_1_1_0.Caption = "章标题";
                    button_1_1_0.Visible = true;

                    button_1_1_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_1_0_Click);

                    button_1_2_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_2_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_2_0.FaceId = 43;
                    button_1_2_0.Caption = "一级条";
                    button_1_2_0.Visible = true;

                    button_1_2_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_2_0_Click);

                    button_1_3_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_3_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_3_0.FaceId = 43;
                    button_1_3_0.Caption = "二级条";
                    button_1_3_0.Visible = true;

                    button_1_3_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_3_0_Click);

                    button_1_4_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_4_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_4_0.FaceId = 43;
                    button_1_4_0.Caption = "三级条";
                    button_1_4_0.Visible = true;

                    button_1_4_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_4_0_Click);

                    button_1_5_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_5_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_5_0.FaceId = 43;
                    button_1_5_0.Caption = "四级条";
                    button_1_5_0.Visible = true;

                    button_1_5_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_5_0_Click);

                    button_1_6_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_6_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_6_0.FaceId = 43;
                    button_1_6_0.Caption = "五级条";
                    button_1_6_0.Visible = true;

                    button_1_6_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_6_0_Click);

                    button_1_7_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_7_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_7_0.FaceId = 43;
                    button_1_7_0.Caption = "无标题条";
                    button_1_7_0.Visible = true;

                    button_1_7_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_7_0_Click);

                    button_1_8_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_8_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_8_0.FaceId = 43;
                    button_1_8_0.Caption = "正文图";
                    button_1_8_0.Visible = true;

                    button_1_8_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_8_0_Click);

                    button_1_9_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_9_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_9_0.FaceId = 43;
                    button_1_9_0.Caption = "正文表";
                    button_1_9_0.Visible = true;

                    button_1_9_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_9_0_Click);

                    button_1_10_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_10_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_10_0.FaceId = 43;
                    button_1_10_0.Caption = "正文公式";
                    button_1_10_0.Visible = true;

                    button_1_10_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_10_0_Click);


                    button_1_11_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_11_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_11_0.FaceId = 43;
                    button_1_11_0.Caption = "段";
                    button_1_11_0.Visible = true;

                    button_1_11_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_11_0_Click);


                    button_1_12_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_12_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_12_0.FaceId = 43;
                    button_1_12_0.Caption = "字母列项";
                    button_1_12_0.Visible = true;

                    button_1_12_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_12_0_Click);

                    button_1_13_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_13_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_13_0.FaceId = 43;
                    button_1_13_0.Caption = "数字列项";
                    button_1_13_0.Visible = true;

                    button_1_13_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_13_0_Click);

                    subbutton_lv1 = (Office.CommandBarPopup)commandToolbar_QRJ_Chapter.Controls.Add(
                       Office.MsoControlType.msoControlPopup,
                         missing, missing, 14, true);

                    subbutton_lv1.Caption = "脚注";
                    {
                        button_1_14_0 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_1_14_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_1_14_0.FaceId = 43;
                        button_1_14_0.Caption = "条文脚注";
                        button_1_14_0.Visible = true;

                        button_1_14_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_14_0_Click);

                        button_1_14_1 = (Office.CommandBarButton)subbutton_lv1.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                        button_1_14_1.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                        button_1_14_1.FaceId = 43;
                        button_1_14_1.Caption = "同号条文脚注";
                        button_1_14_1.Visible = true;

                        button_1_14_1.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_14_1_Click);


                        subbutton_lv2 = (Office.CommandBarPopup)subbutton_lv1.Controls.Add(
                               Office.MsoControlType.msoControlPopup,
                               missing, missing, 3, true);

                        subbutton_lv2.Caption = "图表脚注";

                        {
                            button_1_14_2 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_1_14_2.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_1_14_2.FaceId = 43;
                            button_1_14_2.Caption = "脚注编号";
                            button_1_14_2.Visible = true;

                            button_1_14_2.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_14_2_Click);

                            button_1_14_3 = (Office.CommandBarButton)subbutton_lv2.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                            button_1_14_3.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                            button_1_14_3.FaceId = 43;
                            button_1_14_3.Caption = "脚注内容";
                            button_1_14_3.Visible = true;

                            button_1_14_3.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_14_3_Click);
                        }
                    }

                    button_1_15_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_15_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_15_0.FaceId = 43;
                    button_1_15_0.Caption = "示例";
                    button_1_15_0.Visible = true;

                    button_1_15_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_15_0_Click);

                    button_1_16_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_16_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_16_0.FaceId = 43;
                    button_1_16_0.Caption = "示例X";
                    button_1_16_0.Visible = true;

                    button_1_16_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_16_0_Click);

                    button_1_17_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_17_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_17_0.FaceId = 43;
                    button_1_17_0.Caption = "注";
                    button_1_17_0.Visible = true;

                    button_1_17_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_17_0_Click);

                    button_1_18_0 = (Office.CommandBarButton)commandToolbar_QRJ_Chapter.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_1_18_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_1_18_0.FaceId = 43;
                    button_1_18_0.Caption = "注X";
                    button_1_18_0.Visible = true;

                    button_1_18_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_1_18_0_Click);

                }
            }
            #endregion


            #region ThirdLine
            {
                commandToolbar_QRJ_Appendix = Globals.ThisDocument.GetCommandBar(application, "QRJ_Appendix");
                if (commandToolbar_QRJ_Appendix != null)
                {
                    commandToolbar_QRJ_Appendix.Visible = false;
                    commandToolbar_QRJ_Appendix.Delete();
                }




                {
                    commandToolbar_QRJ_Appendix = application.CommandBars.Add("QRJ_Appendix", Office.MsoBarPosition.msoBarTop, missing, true);

                    commandToolbar_QRJ_Appendix.Visible = true;

                    button_2_1_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_1_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_1_0.FaceId = 43;
                    button_2_1_0.Caption = "附录章";
                    button_2_1_0.Visible = true;

                    button_2_1_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_1_0_Click);

                    button_2_2_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_2_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_2_0.FaceId = 43;
                    button_2_2_0.Caption = "附录一级条";
                    button_2_2_0.Visible = true;

                    button_2_2_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_2_0_Click);

                    button_2_3_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_3_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_3_0.FaceId = 43;
                    button_2_3_0.Caption = "附录二级条";
                    button_2_3_0.Visible = true;

                    button_2_3_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_3_0_Click);

                    button_2_4_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_4_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_4_0.FaceId = 43;
                    button_2_4_0.Caption = "附录三级条";
                    button_2_4_0.Visible = true;

                    button_2_4_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_4_0_Click);

                    button_2_5_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_5_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_5_0.FaceId = 43;
                    button_2_5_0.Caption = "附录四级条";
                    button_2_5_0.Visible = true;

                    button_2_5_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_5_0_Click);


                    button_2_6_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_6_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_6_0.FaceId = 43;
                    button_2_6_0.Caption = "附录五级条";
                    button_2_6_0.Visible = true;

                    button_2_6_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_6_0_Click);


                    button_2_7_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_7_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_7_0.FaceId = 43;
                    button_2_7_0.Caption = "附录图";
                    button_2_7_0.Visible = true;

                    button_2_7_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_7_0_Click);

                    button_2_8_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_8_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_8_0.FaceId = 43;
                    button_2_8_0.Caption = "附录表";
                    button_2_8_0.Visible = true;

                    button_2_8_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_8_0_Click);


                    button_2_9_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_9_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_9_0.FaceId = 43;
                    button_2_9_0.Caption = "附录公式";
                    button_2_9_0.Visible = true;

                    button_2_9_0.Click += new Office._CommandBarButtonEvents_ClickEventHandler(button_2_9_0_Click);


                    button_2_10_0 = (Office.CommandBarButton)commandToolbar_QRJ_Appendix.Controls.Add(Office.MsoControlType.msoControlButton, missing, missing, missing, missing);
                    button_2_10_0.Style = Office.MsoButtonStyle.msoButtonIconAndCaption;
                    button_2_10_0.FaceId = 43;
                    button_2_10_0.Caption = "公式后的破折号";
                    button_2_10_0.Visible = false;

                    button_2_10_0.Enabled = false;
                }
            }
            #endregion
        }

        public void SetCurrentDoc(ref WordDoc d)
        {
            doc = d;
        }

       


        #region VSTO 设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisDocument_Startup);
            this.Shutdown += new System.EventHandler(ThisDocument_Shutdown);
            this.BeforeSave += new Microsoft.Office.Tools.Word.SaveEventHandler(ThisDocument_BeforeSave);
        }

        #endregion
    }
}
